<?PHP
session_start();

include "./php/url.php";
include_once "./php/ini.php";

if (( isset ($_POST["login"])) && ( isset ($_POST["connexion"])))
{
    $login = $_POST['login'];
    $pass = $_POST['pass'];
    dbconnect();

    global $log_tmp;
    global $log_tmp2;
    global $mdp_tmp;
    global $mdp_tmp2;

    //from login
    $requete = "SELECT * FROM users WHERE nom_user='".$login."';";
    $req = mysql_query($requete);
    $r = mysql_fetch_assoc($req);
    $log_tmp = $r['nom_user'];
    $mdp_tmp = $r['pass_user'];

    //from pass
    $requete = "SELECT * FROM users WHERE pass_user='".$pass."';";
    $req = mysql_query($requete);
    $r2 = mysql_fetch_assoc($req);
    $log_tmp2 = $r2['nom_user'];
    $mdp_tmp2 = $r2['pass_user'];

    //compare
    if (($log_tmp != "") && ($mdp_tmp != "") && ($log_tmp == $log_tmp2) && ($mdp_tmp == $mdp_tmp2))
    {
        $sql = "SELECT * FROM users WHERE nom_user='".$login."';";
        $requete = mysql_query($sql);
        if (!$requete)
        {
            echo "SQL error : ", $sql;
            exit ;
        }
        else
        {
            while ($tab = mysql_fetch_assoc($requete))
            {
                if ($tab['compte_active'] == 1)
                {
                    $_SESSION["login"] = $_POST["login"];
                    $_SESSION["id_user"] = $tab['id_user'];

                    if ( isset ($_POST["remember"]))
                    {
                        setcookie("goldname", $_SESSION["login"], time()+60*60*24*61);
                    }
					
                }
            }
        }
    }
	else{
			 echo '<script language="Javascript">

document.location.replace("'.$url.'");

</script>';
	}

    dbclose();
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
    <head>
        <title>Infinity</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	   	<script type="text/javascript">
			var _global_nom;
			var _global_id_user;
			var _global_url;
			_global_url = "http://localhost:8888/terraNumerica/infinity/trunk/";
                 
     	</script>
        <script type="text/javascript" src="./js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="./js/function.js"></script>
        <script type="text/javascript" src="./ajaxfileupload/ajaxfileupload.js"></script>
        <!-- ADDON  FDB -->
        <script type="text/javascript" src="./dibartolo/js/swfobject.js"></script>
        <script type="text/javascript" src="./dibartolo/js/fl_function.js"></script>
        <link rel="stylesheet" type="text/css" href="dibartolo/css/infinity.css" />
        <script type="text/javascript">
            var flashvar = {};
            var param = {};
            param.allowscriptaccess = "always";
            var attribute = {};
            attribute.id = "myId";
            attribute.name = "myFlashContent";
            attribute.styleclass = "Testb";
            swfobject.embedSWF("dibartolo/gallery.swf", "myAlternativeContent", "930", "110", "9.0.0", "expressInstall.swf", flashvar, param, attribute);
        </script>
        <!-- ADDON  FDB -->

		<script type="text/javascript">
			function V2JS_Login_Ready() {
				
				<?PHP
				$login = ( isset ($_SESSION['login']))?'var cmd = "SendMessage \'Level\' \'login\'";':'';
				echo $login;
				?>
				V2JS_Message(cmd);
				var loginResult = document.Virtools.DoCommand(cmd);
			    V2JS_Message('V2JS_Login_Ready dans Javascript');
			}
		</script>


<!-- 	 	<script src="http://3dlifeplayer.dl.3dvia.com/player/install/DetectBrowser.js"></script>
	 	<script src="http://3dlifeplayer.dl.3dvia.com/player/install/3DLifePlayer_last_version.js"></script>
	 	<script src="http://3dlifeplayer.dl.3dvia.com/player/install/3DLifePlayer.js"></script> -->

    </head>

<body>
	
	<div id="header">
	    <?PHP echo '<span class="l1"><a href="'.$url.'" >Infinity</a></span>'; ?>
	</div>
	
	<div id="mainmenu">
		<?PHP
		$deco = ( isset ($_SESSION['login']))?'<input id="btn_deco" type="submit" name="deco" value="Fermer" />':'';
		echo '<form action="index.php" method="post"><div>'.$deco.'</div></form>';
		?>
	</div>
	
	<div class="big1">
		<div id="content">

			<OBJECT id="virtool" CLASSID="CLSID:D4323BF2-006A-4440-A2F5-27E3E7AB25F8" ID="Virtools" WIDTH="800" HEIGHT="500" CODEBASE="http://a532.g.akamai.net/f/532/6712/5m/virtools.download.akamai.com/6712/player/install/installer.exe#Version=4,0,0,26">
				<PARAM NAME="SRC" VALUE="infinityMaquette.vmo">
				<param name="KeepKeyBoard" value="0">
				<EMBED SRC="infinityMaquette.vmo" TYPE="application/x-virtools" PLUGINSPAGE="http://player.virtools.com/" WIDTH="800" HEIGHT="500" NAME="Virtools" KeepKeyBoard="0"></EMBED>
			</OBJECT>

			
			<div id="upload_message">

			</div>
			<!-- INSERT FLASH CAROUSSEL -->
				<script type="text/javascript">
				var flashvars = {};
				var params = {};
				params.allowscriptaccess = "always";
				var attributes = {};
				      	attributes.id = "boardId";
				        attributes.name = "myFlashBoard";
				        attributes.styleclass = "Testencore";
				<?PHP	echo 'swfobject.embedSWF("dibartolo/infinityBoard.swf?uid='.$_SESSION['id_user'].'", "myAlternativeBoard", "300", "480", "9.0.0", "expressInstall.swf", flashvars, params, attributes);'; ?>
				</script>
			<!-- END INSERT FLASH CAROUSSEL -->

			<div id="myAlternativeBoard">
			    <a href="http://www.adobe.com/go/getflashplayer">
					<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
				</a>
			</div>
		</div>

	<!-- DIV IMPORTANTE VERIF !!!! -->
	<div class="upload_img" id="formulaire">&nbsp;</div>
	<!-- DIV IMPORTANTE VERIF !!!! -->

	<?php echo '<script type="text/javascript"> _identification("'.$_SESSION["login"].'"); </script>'; ?>

		<div class="big2">
			<div id="myAlternativeContent">
			<a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>
			</div>
		</div>

	<br/>
	<br/>

	<button id="bouton" onclick="sendToActionScript('2', 'lsd.jpg');">
	    Appel vers AS3
	</button>

	<br/>
	function showMove:
	<button onclick="showMove('1', 'up', '<?PHP echo $_SESSION['id_user'] ?>');">
	    up
	</button>

	<button onclick="showMove('1', 'down', '<?PHP echo $_SESSION['id_user'] ?>');">
	    down
	</button>

	<button onclick="showMove('1', 'left', '<?PHP echo $_SESSION['id_user'] ?>');">
	    left
	</button>

	<button onclick="showMove('1', 'right', '<?PHP echo $_SESSION['id_user'] ?>');">
	    right
	</button>

	<button onclick="showMove('1', 'stop', '<?PHP echo $_SESSION['id_user'] ?>');">
	    stop
	</button>

	<br/>

	<input type='text' id='myangle' size='3' value='177' />

	<button onclick="showMove('2', document.getElementById('myangle').value, '1001');">
	    set angle
	</button>

	</div>
	<div id="vitesse"><input type="button" onclick="changeVitesse(20);" value="x20" /></div>
</body>
</html>
